<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="vacations" mode="admin-vacations-form">
	<div class="calendar-head">
		<h2>Manage Closure Dates</h2>
	</div>
	
	<div class="admin-message">
		<xsl:if test="/data/events/admin-vacations-holidays/@result = 'error'">
			<h4>Errors were encountered when trying to create a new closure date. Please try again.</h4>
		</xsl:if>
		<xsl:if test="/data/events/admin-vacations-holidays/@result = 'success'">
			<h4>Success. A new closure date has successfully been created.</h4>
		</xsl:if>
	</div>
	
	<p><strong>Before you create a closure date</strong>, make sure no appointments ready exist for that date. If appointments have been made for the intended closure date, you may need to inform the client(s) and re-book appointments on other dates.</p>
	
	<div id="admin_new_vacation" class="grid_6 alpha">
		<form method="post" action="" enctype="multipart/form-data">
			<input name="MAX_FILE_SIZE" type="hidden" value="5242880" />
			<label>Create a New
				<select name="fields[reason-closed]">
					<option value="Observed Holiday">Observed Holiday</option>
					<option value="Holiday">Holiday</option>
					<option value="Vacation">Vacation</option>
					<option value="Closed">Closed</option>
				</select>
			</label>
			<div>
				<input id="date_vaca" name="date_vaca" type="text" value="" class="date vacation" />
				<input id="date_of_closure" name="fields[date-of-closure]" type="text" value="" />
				<input name="fields[status]" type="hidden" value="Active" />
				<input name="action[admin-vacations-holidays]" type="submit" value="Submit" />
			</div>
		</form>
	</div>
	<xsl:choose>
		<xsl:when test="error = 'No records found.'">
			<ul id="admin_made_vacations" class="grid_6 omega">
				<li>No future closure dates have been created.</li>
			</ul>
		</xsl:when>
		<xsl:otherwise>
			<ul id="admin_made_vacations" class="grid_6 omega">
				<xsl:apply-templates select="entry" mode="list"/>
			</ul>
		</xsl:otherwise>
	</xsl:choose>

	
</xsl:template>

<xsl:template match="vacations/entry" mode="list">
	<xsl:param name="week-day">
		<xsl:call-template name="get-day-of-the-week-name">
			<xsl:with-param name="date" select="date-of-closure"/>
		</xsl:call-template>
	</xsl:param>
	
	<li>
		<form method="post" action="" enctype="multipart/form-data">
			<h4>
				<xsl:value-of select="normalize-space($week-day)"/>
				<xsl:text>, </xsl:text>
				<xsl:call-template name="get-formatted-date">
					<xsl:with-param name="date" select="date-of-closure"/>
				</xsl:call-template>
				<xsl:text> </xsl:text>
				<input name="MAX_FILE_SIZE" type="hidden" value="5242880" />
				<input name="id" value="{@id}" type="hidden" />
				<input class="cancel-apt" name="action[admin-vacation-delete]" type="image" src="{$root}/workspace/images/delete_blue.png" value="Cancel Appointment" />
			</h4>
			<p>
				<xsl:value-of select="reason-closed/item"/>
			</p>
		</form>
	</li>
</xsl:template>

</xsl:stylesheet>